<script type="text/javascript">
    $.validator.setDefaults({
        submitHandler: function() {
            $.post("<?= site_url() ?>setup/insert_item", {
                item: $('#item').val(),
                qty: $('#qty').val(),
				qty_active: $('#qty_active').val(),
				qty_not_active: $('#qty_not_active').val(),
				status: $('#status').val()
            },
            function(data) {
                window.location = '<?php echo base_url();?>setup/ga_warehouse';
            });
        }
    });

    $(document).ready(function() {
        $("#formuser").keypress(function(e) {
            if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
                $.validator.setDefaults({
                    submitHandler: function() {
                        $.post("<?= site_url() ?>setup/insert_item", {
                            item: $('#item').val(),
							qty: $('#qty').val(),
							qty_active: $('#qty_active').val(),
							qty_not_active: $('#qty_not_active').val(),
							status: $('#status').val()
                        },
                        function(data) {
                            window.location = '<?php echo base_url();?>setup/ga_warehouse';
                        });
                    }
                });
            }
        });

        $("#formuser").validate();
    });

    function cancel() {
        window.location = '<?php echo base_url();?>setup/ga_warehouse';        
    }
</script>

<div id="loader" class="col-md-offset-1">
    <form method="post" id="formuser" action="#" enctype="multipart/form-data" class="form-horizontal" role="form">
        <div class="col-md-11">
			<div class="panel-body well">
				<h4><b class="caret"></b><b> Form - Add Warehouse Item</b></h4>
				<div class="col-sm-8">
					<div class="col-sm-5"><label for="item_name" class="control-label">Item Name<span style="color:red;">*</span></label></div>
					<div class="col-sm-4"><input type="text" class="form-control input-sm required" id="item" name="item" maxlength="30"></div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-5"><label for="item_qty" class="control-label">Item Qty<span style="color:red;">*</span></label></div>
					<div class="col-sm-4"><input type="text" class="form-control input-sm required" id="qty" name="qty" value="0" align="right"></div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-5"><label for="item_qty_a" class="control-label">Item Qty Active<span style="color:red;">*</span></label></div>
					<div class="col-sm-4"><input type="text" class="form-control input-sm required" id="qty_active" name="qty_active" value="0" align="right"></div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-5"><label for="item_qty_n" class="control-label">Item Qty Not Active<span style="color:red;">*</span></label></div>
					<div class="col-sm-4"><input type="text" class="form-control input-sm required" id="qty_not_active" name="qty_not_active" value="0" align="right"></div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-5"><label for="l_status" class="control-label">Item Status<span style="color:red;">*</span></label></div>
					<div class="col-sm-3">
						<select name="status" id="status" class="form-control input-sm required">
							<option value="Y">Active</option>
							<option value="N">Not Active</option>						
						</select>
					</div>
				</div>
				<div class="col-sm-8" style="padding-bottom: 10px;">
					<div class="col-sm-4">
						&nbsp;
					</div>
				</div>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="button" class="control-label">&nbsp;</label></div>
					<div class="col-sm-4">
						<button type="submit" class="btn btn-success btn-block"><!--span class="glyphicon glyphicon-saved"></span--> Save Add</button>
					</div>
					<div class="col-sm-4">
						<button type="button" class="btn btn-default btn-block" onclick="cancel();">
						<!--span class="glyphicon glyphicon-circle-arrow-left"></span--> Cancel</button>
					</div>
				</div>
			</div>
		</div>
    </form>
</div>